﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Cache
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;

#nullable disable
namespace UnityEngine
{
  /// <summary>
  ///   <para>Data structure for cache. Please refer to Additional resources:Caching.AddCache for more information.</para>
  /// </summary>
  [NativeHeader("Runtime/Misc/Cache.h")]
  [StaticAccessor("CacheWrapper", StaticAccessorType.DoubleColon)]
  public struct Cache : IEquatable<Cache>
  {
    private int m_Handle;

    internal int handle => this.m_Handle;

    public static bool operator ==(Cache lhs, Cache rhs) => lhs.handle == rhs.handle;

    public static bool operator !=(Cache lhs, Cache rhs) => lhs.handle != rhs.handle;

    public override int GetHashCode() => this.m_Handle;

    public override bool Equals(object other) => other is Cache other1 && this.Equals(other1);

    public bool Equals(Cache other) => this.handle == other.handle;

    /// <summary>
    ///   <para>Returns true if the cache is valid.</para>
    /// </summary>
    public bool valid => Cache.Cache_IsValid(this.m_Handle);

    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern bool Cache_IsValid(int handle);

    /// <summary>
    ///   <para>Returns true if the cache is ready.</para>
    /// </summary>
    public bool ready => Cache.Cache_IsReady(this.m_Handle);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern bool Cache_IsReady(int handle);

    /// <summary>
    ///   <para>Returns true if the cache is readonly.</para>
    /// </summary>
    public bool readOnly => Cache.Cache_IsReadonly(this.m_Handle);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern bool Cache_IsReadonly(int handle);

    /// <summary>
    ///   <para>Returns the path of the cache.</para>
    /// </summary>
    public string path => Cache.Cache_GetPath(this.m_Handle);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern string Cache_GetPath(int handle);

    /// <summary>
    ///   <para>Returns the index of the cache in the cache list.</para>
    /// </summary>
    public int index => Cache.Cache_GetIndex(this.m_Handle);

    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern int Cache_GetIndex(int handle);

    /// <summary>
    ///   <para>Returns the number of currently unused bytes in the cache.</para>
    /// </summary>
    public long spaceFree => Cache.Cache_GetSpaceFree(this.m_Handle);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern long Cache_GetSpaceFree(int handle);

    /// <summary>
    ///   <para>Allows you to specify the total number of bytes that can be allocated for the cache.</para>
    /// </summary>
    public long maximumAvailableStorageSpace
    {
      get => Cache.Cache_GetMaximumDiskSpaceAvailable(this.m_Handle);
      set => Cache.Cache_SetMaximumDiskSpaceAvailable(this.m_Handle, value);
    }

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern long Cache_GetMaximumDiskSpaceAvailable(int handle);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern void Cache_SetMaximumDiskSpaceAvailable(int handle, long value);

    /// <summary>
    ///   <para>Returns the used disk space in bytes.</para>
    /// </summary>
    public long spaceOccupied => Cache.Cache_GetCachingDiskSpaceUsed(this.m_Handle);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern long Cache_GetCachingDiskSpaceUsed(int handle);

    /// <summary>
    ///   <para>The number of seconds that an AssetBundle may remain unused in the cache before it is automatically deleted.</para>
    /// </summary>
    public int expirationDelay
    {
      get => Cache.Cache_GetExpirationDelay(this.m_Handle);
      set => Cache.Cache_SetExpirationDelay(this.m_Handle, value);
    }

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern int Cache_GetExpirationDelay(int handle);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern void Cache_SetExpirationDelay(int handle, int value);

    /// <summary>
    ///   <para>Removes all cached content in the cache that has been cached by the current application.</para>
    /// </summary>
    /// <param name="expiration">The number of seconds that AssetBundles may remain unused in the cache.</param>
    /// <returns>
    ///   <para>Returns True when cache clearing succeeded.</para>
    /// </returns>
    public bool ClearCache() => Cache.Cache_ClearCache(this.m_Handle);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern bool Cache_ClearCache(int handle);

    /// <summary>
    ///   <para>Removes all cached content in the cache that has been cached by the current application.</para>
    /// </summary>
    /// <param name="expiration">The number of seconds that AssetBundles may remain unused in the cache.</param>
    /// <returns>
    ///   <para>Returns True when cache clearing succeeded.</para>
    /// </returns>
    public bool ClearCache(int expiration)
    {
      return Cache.Cache_ClearCache_Expiration(this.m_Handle, expiration);
    }

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern bool Cache_ClearCache_Expiration(int handle, int expiration);
  }
}
